package com.beasts.ant.auth.config.oauth.handler;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 自定义401错误码内容
 *
 * @author Locker
 * @date 13/05/2018 10:36 AM
 * @since 1.0
 */
@Component
public class SelfAuthenticationEntryPoint implements AuthenticationEntryPoint {

    @Override
    public void commence(HttpServletRequest req, HttpServletResponse resp, AuthenticationException e) throws IOException, ServletException {
        resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, "401: Access Denied");
    }
}
